<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="/res/back/css/base.css" rel="stylesheet" type="text/css" />
<link href="/res/third/bootstrap3/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="/res/common/js/jquery.1.9.1.min.js" type="text/javascript"></script>
<script src="/res/third/bootstrap3/jsone/bootstrap.min.js" type="text/javascript"></script>
<script src="/res/third/artDialog/jquery.artDialog.js" type="text/javascript"></script>
<script src="/res/third/validate/jquery.validate.js" type="text/javascript"></script>
<script type="text/javascript">
	function sosuo(){
		var lpath =location.pathname;
		var pageNo = $("#pageNo").val();
		$("#soform").attr("action",lpath+"?pageNo="+pageNo);
		$("#soform").submit();
	}
	function chooserole(index,text){
		$("#cusrole").val(index);
		$("#cusroleText").val(text);
		var lpath =location.pathname;
		var pageNo = $("#pageNo").val();
		$("#soform").attr("action",lpath+"?pageNo="+pageNo);
		$("#soform").submit();
	}
	function choosestate(index,text){
		$("#cusstate").val(index);
		$("#cusstateText").val(text);
		var lpath =location.pathname;
		var pageNo = $("#pageNo").val();
		$("#soform").attr("action",lpath+"?pageNo="+pageNo);
		$("#soform").submit();
	}
	$(document).ready(function(){
		var cusroleText=$("#cusroleText").val();
		var cusstateText=$("#cusstateText").val();
		if(cusroleText!=""){
			$("#htcr").text(cusroleText);
		}
		if(cusstateText!=""){
			$("#htcs").text(cusstateText);
		}
		$("#catesbut").click(function(){
			if($(".choosecatesul").is(":hidden")){
				$(".choosecatesul").show();
			}else{
				$(".choosecatesul").hide();
			}
		})
	})
</script>
<style type="text/css">
	table{table-layout: fixed;}
	td{white-space: nowrap;overflow: hidden;text-overflow:ellipsis;}
	.chooserole{position: absolute;right: 1px;top: 5px;width: 159px;}
	.choosestate{position: absolute;right: 162px;top:5px;width: 159px;}
	.choosecates{position: absolute;right:324px;top:5px;width: 300px;border: none;}
	.choosecatesul{width: 300px;position: absolute;top:100%;left: 0;z-index: 1000;float: left;min-width: 160px;padding: 5px 0;
		margin: 2px 0 0;font-size: 14px;list-style: none;background-color: #fff;display:none;
		border: 1px solid rgba(0,0,0,0.15);border-radius:4px;box-shadow:0 6px 12px rgba(0,0,0,0.175);background-clip:padding-box;}
	.choosecatesli{font-size: 13px;font-weight: bold;color: black;line-height: 27px;cursor: pointer;}
	.catecheck{float: left;margin:7px 10px 0px 10px!important;cursor: pointer;}
	.choosecatesli:hover{background-color: #f9f9f9;}
	.catesbtn{border-radius:8px;background-color: #fff;height: 33px;text-align: center;line-height: 32px;color: black;border: 1px solid #e2e2e2;cursor: pointer;}
</style>
</head>

<body>
	<div class="panel panel-info panel-content">
	<div class="panel-heading" style="position: relative;">
	
			<div class="btn-group chooserole">
				   <button type="button" class="btn btn-default dropdown-toggle" 
				      data-toggle="dropdown" style="width: 100%;">
				     <span id="htcr">选择商家角色</span><span class="caret"></span>
				   </button>
				   <ul class="dropdown-menu" role="menu">
				      <li><a href="#" onclick="chooserole(1,'采购商')">采购商</a></li>
				      <li><a href="#" onclick="chooserole(2,'供应商')">供应商</a></li>
				      <li class="divider"></li>
				      <li><a href="#" onclick="chooserole(0,'全部商家')">全部商家</a></li>
				   </ul>
			</div>
			
			<div class="btn-group choosestate">
				   <button type="button" class="btn btn-default dropdown-toggle" 
				      data-toggle="dropdown" style="width: 100%;">
				      <span id="htcs">审核状态</span><span class="caret"></span>
				   </button>
				   <ul class="dropdown-menu" role="menu">
				      <li><a href="#" onclick="choosestate(0,'未完善')">未完善</a></li>
				      <li><a href="#" onclick="choosestate(1,'待审核')">待审核</a></li>
				      <li><a href="#" onclick="choosestate(2,'未通过')">未通过</a></li>
				      <li><a href="#" onclick="choosestate(3,'通过')">通过</a></li>
				      <li><a href="#" onclick="choosestate(4,'已删除')">已删除</a></li>
				      <li><a href="#" onclick="choosestate(5,'重新审核')">重新审核</a></li>
				      <li class="divider"></li>
				      <li><a href="#" onclick="choosestate(-1,'全部商家')">全部商家</a></li>
				   </ul>
			</div>
			
			<div class="choosecates">
				   <div style="width: 100%;" id="catesbut" class="catesbtn">
				      <span id="htcates">主营产品系</span><span class="caret"></span>
				   </div>
				   <ul class="choosecatesul">
				      <li class="choosecatesli"><input class="catecheck" type="checkbox">消防报警</li>
				      <li class="choosecatesli"><input class="catecheck" type="checkbox">通风空调</li>
				      <li class="choosecatesli"><input class="catecheck" type="checkbox">建筑设备</li>
				   </ul>
			</div>
			
		<form  id="soform" method="post" >
			<input id="cusrole" type="hidden" name="so_cusrole" value="${so_cusrole!}">
			<input id="cusroleText" type="hidden" name="so_cusroleText" value="${so_cusroleText!}">
			<input id="cusstate" type="hidden" name="so_cusstate" value="${so_cusstate!}">
			<input id="cusstateText" type="hidden" name="so_cusstateText" value="${so_cusstateText!}">
		<table >
			<tr>
				<td>
					<div class="input-group">
						<input type="text" class="form-control"  name="so_customerinfo"  value="${so_customerinfo!}" placeholder="公司名称"> 
						<span class="input-group-btn">
							<button class="btn btn-default" type="button" onclick="sosuo()">搜索</button>
						</span>
					</div>
				</td>
			</tr>
		</table>
		</form>
		</div>
		<table class="table table-hover table-bordered table-striped table-condensed">
			<thead>
				<tr>
					<th width="5%">序号</th>
					<th width="15%">企业名称</th>
					<th width="15%">所在地</th>
					<th width="22%">主营产品系统</th>
					<th width="6%">联系人</th>
					<th width="8%">联系电话</th>
					<th width="8%">提交时间</th>
					<th width="5%">状态</th>
					<th width="4%">产品数</th>
					<th width="11%">操作</th>
				</tr>
			</thead>
			[#list pagination.list as customer]
			<tr>
				<td align="center">${customer_index+1!}</td>
				<td>${customer.company!}</td>
				<td>${customer.province!}${customer.city!}${customer.area!}</td>
				<td>${customer.mpcatename!}</td>
				<td align="center">${customer.contacter!}</td>
				<td align="center">[#if customer.mobile??]${customer.mobile!}[#else]${customer.phone!}[/#if]</td>
				<td align="center">${customer.registertime!}</td>
				<td align="center">${customer.auditStateName!}</td>
				<td>${customer.procount!}</td>
				<td>
				 [#if customer.state!=3]<button type="button" class="btn btn-danger btn-xs delbtn" onclick="audit('${customer.id}')">审核通过</button>[/#if]
				 <button type="button" class="btn btn-danger btn-xs delbtn" onclick="detail('${customer.id}')">查看详情</button>
				</td>
			</tr>
			[/#list]
		</table>

		<div class="panel-footer">[@fenye p = pagination form = 'infoForm' /]</div>
	</div>
</body>
</html>
<script type="text/javascript">
function audit(id){
		v_confirm('是否确认审核通过' , function(){
				$.ajax({
					url : '/customer/ajax_audit.do',
					type : 'post',
					dataType : 'json',
					data : {
						id : id
					},
					beforeSend:function(){
			            art.dialog.tips("审核中...");
			        },
					success : function(data){
						if(data.success){
							location.reload();
						}else{
							error_msg(data.msg , function(){location.reload();});
						}
					}
				});
			});
	}
	
function detail(id){
	var detaildialog =art.dialog({title:"查看"});
	$.ajax({
	    url: '/customer/v_detail.do',
	    data:{id:id},
	    success: function (data) {
	    	detaildialog.content(data);
	    }
	});
}
</script>